#!/usr/bin/perl

use lib::abs qw( .. );
use strict;
use warnings;

use English qw( -no_match_vars );
use Test::More;

BEGIN {
    plan skip_all => "Perl 5.10 required" unless eval { require 5.010; 1 };
    plan tests => 6;
}


BEGIN { use_ok( 'Try::LiteAndTiny', qw( try catch ) ) }

use 5.010;

my ( $foo, $bar, $other );

$ARG = "magic";

try {
    die "foo";
} catch {

    like( $ARG, qr/foo/ );

    when (/bar/) { $bar++ };
    when (/foo/) { $foo++ };
    default { $other++ };
};

is( $ARG, "magic", '$ARG not clobbered' );

ok( !$bar, "bar didn't match" );
ok( $foo, "foo matched" );
ok( !$other, "fallback didn't match" );
